package com.um.jdy.app.shop.controller;

import com.um.jdy.app.shop.entity.vo.GoodsCategoryGoodsVO;
import com.um.jdy.app.shop.entity.vo.GoodsCategoryTreeNodeVO;
import com.um.jdy.app.shop.manager.GoodsCategoryManager;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品分类
 * @author renjunwei
 * @date 2020/9/18 18:10
 */
@Validated
@Api(tags = "商品")
@RestController
@RequestMapping("/api/v1/goods/category/")
public class GoodsCategoryContoller {

    @Autowired
    GoodsCategoryManager goodsCategoryManager;

    /**
     * 查询商品类目树
     * @return
     */
    @ApiOperation("查询商品类目树")
    @GetMapping("tree")
    public Response<List<GoodsCategoryTreeNodeVO>> getTree(){
        return Response.success(goodsCategoryManager.getTree());
    }

    /**
     * 查询一级类目及商品
     * @return
     */
    @ApiOperation("查询一级类目及商品")
    @GetMapping()
    public Response<List<GoodsCategoryGoodsVO>> getCategoryAndGoods(){
        return Response.success(goodsCategoryManager.getCategoryAndGoods());
    }
}
